package com.batchOperation.excel.support;

import com.alibaba.excel.event.AnalysisEventListener;
import com.batchOperation.excel.model.Employee;
import com.batchOperation.excel.model.SchoolInfo;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Package: com.batchOperation.excel.support
 * @ClassName: ContentHolder
 * @Author: h2cloud
 * @CreateTime: 2024/7/18 11:14 下午
 * @Description: 映射处理类
 */
public class MappingHandler {
	// todo 注解扫描优化
	public static Map<String, Class> entity2Class = new ConcurrentHashMap<>();
	public static Map<String, String> entity2SheetName = new ConcurrentHashMap<>();
	public static Map<String, String> sheetName2Entity = new ConcurrentHashMap<>();
	public static Map<String, AnalysisEventListener<?>> entity2Listener = new ConcurrentHashMap<>();

	static {
		entity2Class.put("Employee", Employee.class);
		entity2Class.put("SchoolInfo", SchoolInfo.class);

		entity2SheetName.put("Employee", "人员信息");
		entity2SheetName.put("SchoolInfo", "学校信息");

		sheetName2Entity.put("人员信息", "Employee");
		sheetName2Entity.put("学校信息", "SchoolInfo");
	}

	public static Class getClassBySheetName(String sheetName) {
		String entity = sheetName2Entity.get(sheetName);
		return entity2Class.get(entity);
	}
}
